//
//  BYPch.h
//  ZhiHuiLiJiang
//
//  Created by 胡忠诚 on 2018/11/19.
//  Copyright © 2018 WisdomLijiang. All rights reserved.
//BY的pch文件

#ifndef BYPch_h
#define BYPch_h

//打印
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);//将打印内容前的时间戳，改为类名：行号
#else
#define NSLog(...)
#endif

//设备
#define BY_IS_PHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define BY_IS_PAD   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

//版本
#define BY_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

//弱引用
#define BY_kWeakSelf(weakSelf) __weak __typeof(&*self) weakSelf = self;

//屏幕宽高
#define BY_ScreenHeight [UIScreen mainScreen].bounds.size.height
#define BY_ScreenWidth [UIScreen mainScreen].bounds.size.width

//app版本
#define BY_APP_VERSION ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"])
//iphone 宽度 、高度、字体大小
#define BY_FontSize(PT) [UIFont systemFontOfSize:(PT *0.5*(BY_ScreenWidth/375.f))]
#define BY_BoldFontSize(PT) [UIFont boldSystemFontOfSize:(PT *0.5*(BY_ScreenWidth/375.f))]
#define BY_Width(width) ((BY_ScreenWidth/(375.f)) * ((width)*0.5))
#define BY_Height(height) ((BY_ScreenHeight/(667.f)) * ((height)*0.5))

//iPhoneX相关
#define BYiPhoneXorXs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
#define BYiPhoneXr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
#define BYiPhoneXMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)

#define BY_IS_iPhoneX (BYiPhoneXorXs || BYiPhoneXr || BYiPhoneXMax)
#define BY_StatusBar_H (BY_IS_iPhoneX ? 44 : 20)
#define BY_Nav_H (BY_IS_iPhoneX ? 88 : 64)
#define BY_Bot_H (BY_IS_iPhoneX ? 34 : 0)
#define BY_NavBot_H (BY_IS_iPhoneX ? 122 : 64)

//排空
#define BYSafeStr(f) (BYStrValid(f) ? f:@"")//获取到一个安全的字符串
#define BYStrValid(f) (f!=nil && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])//判断是否是一个有效的字符串
#define BYHasString(str,eky) ([str rangeOfString:key].location!=NSNotFound)//判断在字符串str中有没有eky
#define BYValidDict(f) (f!=nil && [f isKindOfClass:[NSDictionary class]])//判断是否是一个有效的字典
#define BYSafeDict(f) (BYValidDict(f) ? f : @{})//获取一个安全的字典
#define BYValidArray(f) (f!=nil && [f isKindOfClass:[NSArray class]] && [f count]>0)//判断是否是一个有效的数组
#define BYSafeNum(f) (BYValidNum(f) ? f : @-1) //获取到一个安全的NSNumber
#define BYValidNum(f) (f!=nil && [f isKindOfClass:[NSNumber class]])//判断是否是一个有效的NSNumber
#define BYValidClass(f,cls) (f!=nil && [f isKindOfClass:[cls class]])//判断是否是一个有效的类
#define BYValidData(f) (f!=nil && [f isKindOfClass:[NSData class]])//判断是否是一个有效的NSData

//完美单例的 声明BYSingtonH 与实现BYSingtonM (alloc、new、shareName、copy、mutableCopy)
#define BYSingtonH(name) +(instancetype)share##name;
#define BYSingtonM(name) static id _instance;\
+ (instancetype)allocWithZone:(struct _NSZone *)zone{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [super allocWithZone:zone];\
});\
return _instance;\
}\
+ (instancetype)share##name{\
return [[self alloc]init];\
}\
- (id)copyWithZone:(NSZone *)zone{\
return _instance;\
}\
- (id)mutableCopyWithZone:(NSZone *)zone{\
return _instance;\
}\

#import "UIColor+BYHexColor.h"//十六进制Color
#import "UIButton+BYAddTag.h"//按钮点击事件的分类
#import "BYViewSingle.h" //搭建界面的单例
#import "UIViewController+BYAlert.h"//弹框事件
#import "UIScrollView+BYTouch.h"//ScrollView上点击touchesBegan
#import "UIView+BYVC.h"//获取当前View的控制器
#import "BYRegular.h"//正则表达式
#import "BYWebVC.h"//webView的控制器
#import "BYWebView.h"//通用的WebView
#import "MBProgressHUD+BYHud.h"//遮罩
#import "BYNetworking.h"//网络请求
#import "UIView+MJAlertView.h"//吐丝框
#import "NSDictionary+BYDic.h"//字典
#include "OpenUDID.h"//唯一标识
#import "BYUserData.h"//用户信息
#import "BYUserManager.h"//用户信息管理
#import "BYSaveCacheData.h"//本地存储数据
#import "MJExtension.h"//字典转模型
#import "UIImageView+WebCache.h" //SDWebImage
#import "NSString+BYCheck.h"//字符串解析




//字体
#define BYPTFont14 BY_FontSize(14)
#define BYPTFont16 BY_FontSize(16)
#define BYPTFont18 BY_FontSize(18)
#define BYPTFont22 BY_FontSize(22)
#define BYPTFont24 BY_FontSize(24)
#define BYPTBoldFont26 BY_BoldFontSize(26)
#define BYPTFont26 BY_FontSize(26)
#define BYPTFont28 BY_FontSize(28)
#define BYPTFont29 BY_FontSize(29)
#define BYPTFont32 BY_FontSize(32)
#define BYPTFont34 BY_FontSize(34)
#define BYPTFont36 BY_FontSize(36)
#define BYPTBoldFont36 BY_BoldFontSize(36)
#define BYPTFont56 BY_FontSize(56)
#define BYPTFont60 BY_FontSize(60)

//颜色
#define BYClearColor [UIColor clearColor]
#define BYWhiteColor [UIColor whiteColor]
#define BYRedColor [UIColor redColor]
#define BYCyanColor [UIColor cyanColor]
#define BYGrayColor [UIColor grayColor]
#define BYOrangeColor [UIColor orangeColor]
#define BYLightGrayColor [UIColor lightGrayColor]
#define BYBlackColor [UIColor blackColor]
#define BYRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0f green:arc4random_uniform(256)/255.0f blue:arc4random_uniform(256)/255.0f alpha:0.3]//随机色
#define BYRGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]//BYRGBA(51,51,51,1)

#define BYColor1 BYRGBA(52,52,52,1.0) //黑色（选择身份）
#define BYColor2 BYRGBA(0,0,0,0.8) //黑色（我是游客）
#define BYColor3 BYRGBA(255,255,255,0.86) //白色（选择身份-完成文字）
#define BYColor4 BYRGBA(255,104,104,1.0) //红色（选择身份-完成背景）
#define BYColor5 BYRGBA(88,88,88,1.0) //黑色（+86）
#define BYColor6 BYRGBA(153,153,153,1.0) //灰色（+86 下划线）
#define BYColor7 BYRGBA(170,170,170,1.0) //灰色（协议前面的字）
#define BYColor8 BYRGBA(104,104,104,1.0) //灰色（登录前的头部背景）
#define BYColor9 BYRGBA(255,255,255,1.0) //白色
#define BYColor10 BYRGBA(152,152,152,1.0) //黑灰色

//回到前台的通知
#define  BYEnterForeground @"UIApplicationDidBecomeActiveNotification_BY"

//回到前台的通知
#define  BYSetting @"UIApplicationDidsetting"

#endif /* BYPch_h */
